﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>购买记录</title>
    <#--要在script前引入-->
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $('.btn-input').click(function () {

                //清除模态框中表单里的旧有数据
                $('#editForm')[0].reset();
                //设置标题
                $('.modal-title').html('购买记录新增');

                var data = $(this).data('json');
                //console.log(this);
                if(data){
                    $('.modal-title').html('购买记录编辑');
                    $('input[name=id]').val(data.id);
                    $('input[name="customer.id"]').val(data.customerId);
                    $('input[name=sn]').val(data.sn);
                }


                $('#editModal').modal('show');
            });
            $('.btn-input1').click(function () {

                //清除模态框中表单里的旧有数据
                $('#editForm1')[0].reset();
                $('#editModal1').modal('show');
            });


            $('.btn-submit').click(function () {
                $('#editForm').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });
            $('.btn-submit1').click(function () {
                $('#editForm1').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });


        })
    </script>


</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu = "buyRecord">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>购买记录</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/buyRecord/list" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入客户名字">
                    </div>
                <#--<@shiro.hasAnyRoles name="admin,Market_Manager">-->
                    <div class="form-group">
                        <label for="dept"> 销售人:</label>

                            <select class="form-control" name="courseId">
                                <option value="-1">学科</option>
                            <#list courses as course>
                                <option value="${course.id}"  <#if course.id==qo.courseId>selected</#if>   >${course.title}</option>
                            </#list>
                            </select>
                    <#--<%--<script>
                        $("#dept option[value='${qo.deptId}']").prop("selected", true);
                    </script>--%>-->
                    </div>
                <#--</@shiro.hasAnyRoles>-->
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                    <a  class="btn btn-success btn-input1" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户名称</th>
                            <th>课程</th>
                            <th>购买时间</th>
                            <th>购买金额</th>
                            <th>操作</th>
                        </tr>
                        <#list pageInfo.list as buyRecord>
                            <tr>
                                <td>${buyRecord_index+1}</td>
                                <td>${buyRecord.customer.name}</td>
                                <td>${buyRecord.course.title}</td>
                                <td>${buyRecord.inputTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                <td>${buyRecord.money}</td>
                                <td>
                                    <a data-json='${buyRecord.jsonData}' class="btn btn-info btn-xs btn-input">
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>

                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<!---购买记录编辑--->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">部门编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/buyRecord/saveOrUpdate" method="post" id="editForm">
                    <input type="hidden"  name="id">
                    <input type="hidden"  name="customer.id">
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">客户名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="customer.name" readonly >
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">课程：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="course.name" >
                            <input type="hidden" class="form-control"  name="course.id" >
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-3 control-label">购买时间：</label>
                        <div class="col-lg-6 ">
                            <input type="text" class="form-control datepicker"  name="inputTime" <#--onfocus="WdatePicker()"--> >
                            <script>
                                $('.datepicker').datepicker({

                                    language: 'zh-CN',
                                    autoclose: true,
                                    todayHighlight: true, // 今天时间高亮
                                    format: 'yyyy-mm-dd',
                                    endDate:new Date() // 今天之后的日期都不可以选择

                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">购买金额：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="money" >
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn-submit">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>

<#--购买记录新增-->
<div class="modal fade" id="editModal1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">购买记录新增</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/buyRecord/saveOrUpdate" method="post" id="editForm1">
                    <input type="hidden"  name="id">
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">选择客户：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="customer.id">
                            <#list customers as customer>
                                <option value="${customer.id}">${customer.name}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">选择课程：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="course.id">
                            <#list courses as course>
                                <option value="${course.id}">${course.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">购买金额：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="money" >
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn-submit1">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
